<?php
class Home extends 	PageBase {


		private function Refresh($offset, $rows){
	   try{
            $this->PropelInit();
           	$c = new Criteria();
           	$c->addAscendingOrderByColumn(UsuarioPeer::NOMBREYAPELLIDO);


    	}
    	catch(Exception $e){
    		$this->LogError($e);
    	}
	}

		public function onInit($param){
			parent::onInit($param);
			$this->dgDatos->DataSource = UsuarioPeer::UsuariosHome();
			$this->dgDatos->dataBind();
		}

		public function dgDatos_OnPageIndexChanged($sender,$param){
			$this->dgDatos->CurrentPageIndex	= 	$param->NewPageIndex;
			$pageSize 							= 	$this->dgDatos->PageSize;
			$offset 							= 	$param->NewPageIndex*$pageSize;
			$this->dgDatos->DataSource 			= 	$this->Bind($offset, $pageSize);
			$this->dgDatos->dataBind();
		}

		public function dgDatos_OnPagerCreated($sender,$param){

		//	$cantUsers = UsuarioPeer::doCount(doCount($c, true);
//			$this->dgDatos->VirtualItemCount = $cantUsers;
//			$c->setOffset($offset);
//			$c->setLimit($rows);
//
//			$users = UsuarioPeer::doSelect($c);
//			$this->dgDatos->DataSource = $users;
//			$this->dgDatos->dataBind();

			//	$param->Pager->Controls->insertAt(0,"P&aacute;gina " . $startPageIndex . " a " . $endPageIndex . " de " . $pageCount . ": ");
		}


		protected function Bind($offset, $rows){
			$filtro = $this->txtBusqueda->Text;
			$this->dgDatos->DataSource = UsuarioPeer::UsuariosHome($filtro);
			$this->dgDatos->dataBind();
		}

		public function btnBuscar_OnClick($sender, $param){
			$this->Bind(0, $this->dgDatos->PageSize);
			if($this->dgDatos->Items->Count>0){
				$this->lblBusqueda->Text = "";
			}
			else{
				$this->lblBusqueda->Text = "No se han encontrado datos para la consulta especificada.";
			}
		}

}
?>